import sun.security.krb5.internal.TGSRep;

public class SynchronizedTest {
    static Object t2=new Object();

    public static void main(String[] args) {
        SynchronizedTest st = new SynchronizedTest();
        Thread t = new Thread(() -> {
            try {
                st.lock();

            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        Thread t2 = new Thread(() -> {
            try {
                st.print();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        Thread t3 = new Thread(() -> {
            try {
                print2();
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        Thread t4 = new Thread(() -> {
            try {
                lock2();
            } catch (Exception e) {
                e.printStackTrace();
            }
        });
        t.start();
        t2.start();

        t4.start();
        t3.start();
    }

     void lock() throws InterruptedException {
        synchronized (t2) {

            Thread.sleep(10000000);
        }
    }

     void print() throws InterruptedException {
                while (true) {
                    Thread.sleep(1000);
                    System.out.println("s");
                }


    }
    synchronized static void lock2() throws Exception {
        while (true) {
            Thread.sleep(10000000);
        }
    }
     static void print2() throws Exception {
        while (true) {
            Thread.sleep(1000);
            System.out.println("s2");
        }
    }


}
